#include <iostream>
#include "TcpServer.h"
#include <string>
#include <signal.h>  
using namespace std;
TcpServer* serverPtr = nullptr;
void Stop(int sig) {
    cout << "server stop sig::" << sig <<  endl;
    // if (sig == 2) {
    //     serverPtr->Stop();
    //     delete serverPtr;
    //     exit(0);
    // }
    if (serverPtr) {
        serverPtr->Stop();
        serverPtr = nullptr;
    }
}
int main() {

    signal(SIGTERM, Stop);
    signal(SIGINT, Stop);

    TcpServer server("0.0.0.0", 9999);
    serverPtr = &server;
    cout << "server start" << endl;
    server.Run();
    
    return 0;
}